<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">
<ui:composition template="/template/system.xhtml">
	<ui:define name="content">
		<h:outputText value="Bem vindo #{usuarioSessionController.usuario.username}..." />
		<h:form prependId="false">
			<p:commandButton actionListener="#{contatoController.prepareAddModel}"
				value="Novo Contato" update="contatoForm" oncomplete="dialogGerContato.show()" />
			<p:dataTable id="tabela" var="contato" value="#{contatoController.listDataModel}">
				<p:column>
					<f:facet name="header">
						<h:outputText value="Nome" />
					</f:facet>
					<h:outputText value="#{contato.nome}" />
				</p:column>
				<p:column>
					<f:facet name="header">
						<h:outputText value="Endere&ccedil;o" />
					</f:facet>
					<h:outputText value="#{contato.endereco}" />
				</p:column>
				<p:column>
					<f:facet name="header">
						<h:outputText value="Alterar" />
					</f:facet>
					<p:commandButton
						actionListener="#{contatoController.prepareEditModel}"
						value="Alterar" update="contatoForm"
						oncomplete="dialogGerContato.show()" />
				</p:column>
				<p:column>
					<f:facet name="header">
						<h:outputText value="Excluir" />
					</f:facet>
					<h:commandLink action="#{contatoController.deleteModel}"
						value="Excluir" />
				</p:column>
			</p:dataTable>
		</h:form>
		<p:dialog header="Gerenciamento de contato" widgetVar="dialogGerContato"
			resizable="false" modal="true" showEffect="slide" width="500">
			<h:form prependId="false">
				<h:panelGrid id="contatoForm" columns="2" style="margin-bottom:10px">
					<h:outputLabel for="contato" value="Contato" />
					<h:inputText id="contato" value="#{contatoController.model.nome}" />
					<h:outputLabel for="endereco" value="Endere&ccedil;o" />
					<h:inputText id="endereco" value="#{contatoController.model.endereco}" />
					<p:commandButton update="tabela,messages" oncomplete="dialogGerContato.hide();"
						actionListener="#{contatoController.saveModel}" value="Salvar" />
				</h:panelGrid>
			</h:form>
		</p:dialog>
	</ui:define>
</ui:composition>
</html>